package com.woniu.supermarket.web;

import com.woniu.supermarket.entity.PurchaseReturnCheck;
import com.woniu.supermarket.result.ResultResponse;
import com.woniu.supermarket.service.IPurchaseReturnCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("PurchaseReturnCheck")
@Api(value = "采购退货审核操作")
public class PurchaseReturnCheckController {

    @Autowired
    IPurchaseReturnCheckService iPurchaseReturnCheckService;

    @GetMapping("/findPurchaseReturnCheckByCode")
    @ApiOperation(value = "根据采购退货单号查询审核信息")
    public ResultResponse<List<PurchaseReturnCheck>> findPurchaseReturnCheckByCode(@RequestParam("returnNumber") String code){
        ResultResponse<List<PurchaseReturnCheck>> result = null;
        try {
            List<PurchaseReturnCheck> lists = iPurchaseReturnCheckService.findPurchaseReturnCheckByCode(code);
            System.out.println(lists);
            result = new ResultResponse<>(200,"查询审核信息成功",lists);
        }catch (RuntimeException e){
            e.printStackTrace();
            result = new ResultResponse<>(201,"查询审核信息失败");
        }
        return result;
    }

}
